package com.exigen.performance.test.webapp.dao;

import java.util.List;

import javax.persistence.Query;

import com.exigen.performance.test.webapp.domain.ConfigurationEntity;
import com.exigen.performance.test.webapp.domain.base.GenericJPADAO;

/**
 * Class that collect configuration data
 * 
 * @author Maksim Savchuk
 * 
 */
public class ConfigurationJpaDao extends
		GenericJPADAO<ConfigurationEntity, Long> implements ConfigurationDao {

	private final String query1 = "select c from ConfigurationEntity c where c.name=:name";

	public ConfigurationJpaDao() {
		super(ConfigurationEntity.class);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.exigen.performance.test.webapp.dao.ConfigurationDao#
	 * getConfigurationByName(java.lang.String)
	 */
	public ConfigurationEntity getConfigurationByName(String configurationName) {
		Query query = getEntityManager().createQuery(query1);
		query.setParameter("name", configurationName);
		@SuppressWarnings("unchecked")
		List<ConfigurationEntity> result = query.getResultList();
		return result.get(0);

	}

}
